if __name__ == '__main__':

    import pandas as pd
    import 小区健康度.Batch as Batch

    df = pd.read_csv(f"D:\\网管\\{Batch.batch}最新sn数据.csv", usecols=['OLTPON', '网元IP'])
    df['slot'] = df['OLTPON'].str.split("-").str[3]
    df.groupby(['网元IP']).agg(
        用户数=('slot', 'count'),
        板卡数=('slot', 'nunique')
    ).reset_index(names=['olt_ip']).to_csv('/网管/用户数和板卡数.csv', index=False)
